Skip to content

Release#100

Merged
ifaouibadi merged 8 commits intomainfrom
develop
Mar 31, 2026
Merged

Release#100
ifaouibadi merged 8 commits intomainfrom
develop

Conversation

@ifaouibadi
Copy link
Copy Markdown
Member

@ifaouibadi ifaouibadi commented Mar 31, 2026

Note

Medium Risk
Touches portfolio/PnL calculation logic and introduces new non-trivial SQL aggregates, so incorrect semantics or edge cases could affect reported financial metrics. Changes are covered by expanded unit tests but still warrant careful validation against real data.

Overview
Adds a new portfolio stats API: GET /accounts/:address/portfolio/stats accepts optional startDate/endDate and returns aggregated trading metrics (top win, unrealized profit, win rate, avg hold duration, trade counts), resolving name addresses via PortfolioService.resolveAccountAddress.

Refactors PnL semantics and batching: BclPnlService now distinguishes cumulative PnL (all-time invested/spent vs proceeds + current value, including closed positions) from range-based PnL (realized gains only), adds a timestamp-windowed calculateDailyPnlBatch SQL path for per-day calendars, and updates PortfolioService to compute range PnL via these per-day windows (keyed by timestamp) instead of a second block-height batch.

Also improves developer/ops robustness: scripts/db-restore.sh resets the local DB user password after restore, and AePricingService.pullAndSaveCoinCurrencyRates falls back to the latest persisted rates if saving new rates fails.

Written by Cursor Bugbot for commit 11e9cc5. This will update automatically on new commits. Configure here.

@ifaouibadi ifaouibadi merged commit d2fd9f3 into main Mar 31, 2026
7 checks passed
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

created_at: 'DESC',
},
});
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Save error silently swallowed without logging

Low Severity

The new catch block in pullAndSaveCoinCurrencyRates swallows the error from coinPriceRepository.save without logging it. If saves fail persistently (e.g., disk full, constraint violations), this would go completely unnoticed in production. The fallback to findOne is a fine recovery strategy, but the original error information is lost, making diagnosis of recurring save failures very difficult.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants